package junit;



import static org.junit.Assert.*;

import java.awt.CardLayout;
import java.util.Iterator;
import org.junit.Before;
import org.junit.Test;

import main.Display;


/**
 * 
 * @author Nick
 * 
 * This is a JUnit test to make sure the panel switching method
 * switches to the appropriate panels.
 *
 */
public class PanelSwitchingTest {

	private Display disp;
	
	/**
	 * sets up the display class for panel switching testing
	 */
	@Before
	public void setUp(){
		disp = new Display();
		disp.initialize();
	}
	
	/**
	 * checks if Display switches to the appropriate panel
	 * (or to do nothing if there is invalid input
	 */
	@Test
	public void testAppend(){
		//make sure the first panel is originally the previous and current panel
		assertTrue(disp.getPrev_panel() == 1);
		assertTrue(disp.getCur_panel() == 1);
		//switch to panel 2
		disp.switchMainPanel(2);
		assertTrue(disp.getCur_panel() == 2);
		assertTrue(disp.getPrev_panel() == 1);
		//switch to panel 3
		disp.switchMainPanel(3);
		assertTrue(disp.getCur_panel() == 3);
		assertTrue(disp.getPrev_panel() == 2);
		//switch to an invalid panel
		disp.switchMainPanel(40);
		assertTrue(disp.getCur_panel() == 3);
		assertTrue(disp.getPrev_panel() == 2);
		//switch to an invalid panel
		disp.switchMainPanel(-10);
		assertTrue(disp.getCur_panel() == 3);
		assertTrue(disp.getPrev_panel() == 2);
		//switch back to 2
		disp.switchMainPanel(disp.getPrev_panel());
		assertTrue(disp.getCur_panel() == 2);
		assertTrue(disp.getPrev_panel() == 3);
		//what this I dont even
		disp.switchMainPanel(disp.getCur_panel());
		assertTrue(disp.getCur_panel() == 2);
		assertTrue(disp.getPrev_panel() == 2);
	}
}
